//
//  HmMacro.h
//  SmartHomeSDK
//
//  Created by haimen_ios_imac on 2017/5/17.
//  Copyright © 2017年 深圳海曼科技有限公司. All rights reserved.
//

/* 宏定义集中管理 */
#ifndef TCMacro_h
#define TCMacro_h

#ifdef DEBUG
#define LOG(...) NSLog(__VA_ARGS__)
#define LOG_FUNC() NSLog(@"%s", __func__)
#define console(...) NSLog(__VA_ARGS__)
#else
#define LOG(...)
#define LOG_FUNC(...)
#define console(...)
#endif

#define APP_STATU_HEIGHT 20.0f;

#define HSHalfPixel(pixel) (pixel)/2.0

#define BUNDLE_PLIST_FILE(name) [[NSBundle mainBundle] pathForResource:name ofType:@"plist"]

#define BUNDLE_IMAGE(image)  [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:(image) ofType:@"jpg"]]

#define DEVICE_IS_PAD               ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad )
#define DEVICE_IS_PHONE             ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone )
#define DEVICE_IS_IPHONE6PLUS       ( [[UIScreen mainScreen] bounds].size.height == 736 )
#define DEVICE_IS_IPHONE6           ( [[UIScreen mainScreen] bounds].size.height == 667 )
#define DEVICE_IS_IPHONE5           ( [[UIScreen mainScreen] bounds].size.height == 568 )
#define DEVICE_IS_IPHONE4           ( [[UIScreen mainScreen] bounds].size.height == 480 )
#define DEVICE_LOW_IPHONE6          ( [[UIScreen mainScreen] bounds].size.height < 667 )

#define SCREEN_WIDTH  [UIScreen mainScreen].bounds.size.width

#define SCREEN_HEIGHT  [UIScreen mainScreen].bounds.size.height

#define SCREEN_SCALE_HEIGHT ((SCREEN_HEIGHT == 736.0)? (1.0):((SCREEN_HEIGHT == 667.0)? (667.0/736.0):(568.0/736.0)))

#define IPhone4s ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)

#define IPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)

#define IPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)

#define IPhone6p ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)

#define ScaleWide (IPhone5 ? 0.8533 : (IPhone6 ? 1.0000 :(IPhone6p ? 1.1040 : 1.0000)))
#define SCALE_WIDTH(W)   ScaleWide * W

#define ScaleHigh (IPhone5 ? 0.8516 : (IPhone6 ? 1.0000 :(IPhone6p ? 1.1034 : 1.0000)))
#define SCALE_HEIGHT(H)    ScaleHigh * H

#define CURRENT_VERSION ( [[[UIDevice currentDevice] systemVersion] floatValue] )

#define RAND_COLOR [UIColor colorWithRed:(arc4random()%256/255.0) green:(arc4random()%256/255.0) blue:(arc4random()%256/255.0) alpha:arc4random()%256/255.0]

#define RGBA_COLOR(rgbValue)   ( [UIColor colorWithRed:((CGFloat)((rgbValue&0xFF000000)>>24))/255.0f \
green:((CGFloat)((rgbValue&0xFF0000)>>16))/255.0f \
blue:((CGFloat)((rgbValue&0xFF00)>>8))/255.0f  \
alpha:((CGFloat)(rgbValue&0xFF))/255.0f] )

#define COLOR(R,G,B,A)  ([UIColor colorWithRed:(R)/255.0 green:(G)/255.0 blue:(B)/255.0 alpha:(A)/10.0])

#define LS_APP(key) NSLocalizedString(key, nil)

#define USER_DIRECTORY  NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES)[0]

#define APP_NAVIGATION_BAR_HEIGHT 64.0f

#define WS(weakSelf)  __weak __typeof(&*self)weakSelf = self

#define PROFILE_VIEW_WIDTH SCREEN_WIDTH*(550/750.0f)

#define LIGHT_BLACK_COLOR COLOR(60.0f, 60.0f, 60.0f, 10.0f)

#define UIImageImage(image)  [UIImage imageNamed:(image)]

#define UIFONTFONT(fontSize) [UIFont systemFontOfSize:fontSize]

#endif /* TCMacro */
